<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="org.jbpm.api.ProcessEngine"%>
<%@page import="org.jbpm.api.Configuration"%>

<%@page import="org.jbpm.api.TaskService"%>
<%@page import="java.util.List"%>
<%@page import="org.jbpm.api.task.Task"%>
<%@page import="org.jbpm.api.RepositoryService"%>
<%@page import="java.util.Date"%>
<%@page import="com.su.mw.mscthesis.util.MScThesisUtils"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Review Proposals</title>
</head>

<%
	String authorized = (String) session.getAttribute("authorized");
	String groupID = (String) session.getAttribute("groupid");
	if (authorized == null || !authorized.equals("yes") || 
		groupID == null || !groupID.equals("professors"))
	{
%>
	<jsp:forward page="login.jsp">
		<jsp:param name="authorizedPage" value="reviewProposals.jsp" />	
		<jsp:param name="desiredGroupID" value="professors" />	
	</jsp:forward>
<%
	}
	ProcessEngine engine = MScThesisUtils.PROCESS_ENGINE;

	TaskService ts = engine.getTaskService();
	
	String professorID = (String) session.getAttribute("userid");
	if (professorID == null || professorID.length() == 0) {
		out.println("ProfessorID should be in the session!");
		return;
	}
	List<Task> tasks = ts.createTaskQuery().processDefinitionId(MScThesisUtils.PROCESS_DEFINITION_ID).activityName("review proposal").assignee(professorID).list();
%>
<body id="movie">
<div id="banner"><img src="SU-logo.png" height="110px"
	border="10px" />
<h2>Welcome to the FMI thesis system! Use links below to browse
functionality.</h2>
<br />
<br />
</div>
<div id="columns"><jsp:include page="indexLinks.jsp" />
<div id="main">
<table cellpadding="1" cellspacing="2" border="0">
	<tr>
		<th bgcolor="#CCCCFF" colspan="3"><font size='5'>MASTER THESIS PROPOSALS</font><br/></th>
	</tr>
	<%
		for (Task task : tasks) {
			String title = (String) ts.getVariable(task.getId(), "title");
			if (title != null) {
	%>
	<tr>
		<td>
		<table cellpadding=1 cellspacing=2 border=0>
		<tr>
		<th bgcolor="#CCCCFF" colspan="3"><font size='5'><% out.print(title); %></font><br/>
		</th>
	</tr>
			<tr bgcolor="#c8d8f8">
				<td align="left" colspan="2" ><b>Annotation</b>
				<textarea name="annotation" rows="1" cols="60" readonly="readonly"><% out.print(ts.getVariable(task.getId(), "annotation")); %></textarea></td>
			</tr>
			<tr bgcolor="#c8d8f8">
				<td align="left" colspan="2" ><b>Description</b>
				<textarea name="description" readonly="readonly" rows="1" cols="60"><% out.print(ts.getVariable(task.getId(), "description")); %></textarea></td>
			</tr>
			<tr bgcolor="#c8d8f8">
				<td align="left" colspan="2"><b>Programming Technologies</b>
				<textarea readonly="readonly" name="programmingTechnologies" rows="1" cols="60"><% out.print(ts.getVariable(task.getId(), "programmingTechnologies")); %></textarea></td>
			</tr>
			<tr bgcolor="#c8d8f8">
				<td align="left"><b>Consultant</b>
				<input type="text" readonly="readonly" name="consultantName" value="<% out.print(ts.getVariable(task.getId(), "consultantName")); %>" size=25 maxlength=125 />
				</td>
				<td align="left"><b>Execution time</b>
				<input type="text" name="executionTime" readonly="readonly" value="<% out.print(ts.getVariable(task.getId(), "executionTime")); %>" size=5 maxlength=2 /></td>
			</tr>
			<tr bgcolor="#c8d8f8">
				<td align="left"><b>Student ID</b>
				<input readonly="readonly" type="text" name="student" size=10 value="<% out.print(ts.getVariable(task.getId(), "student")); %>" maxlength=10 /></td>
				<td align="left"><b>Submission date</b>
				<input type="text" name="submitted" readonly="readonly" size=10 value="<% out.print(ts.getVariable(task.getId(), "submitted")); %>" maxlength=10 /></td>
			</tr>
			<tr bgcolor="#c8d8f8">
				<td align=center colspan=2>
				<form action="updateProposalStatus.jsp" method="post">
					<input type="submit" name="status" value="Accept" />
					<input type="submit" name="status" value="Reject" />
					<input type="hidden" name="taskId" value="<%out.print(task.getId()); %>" />
				</form>			
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<%
		}
		}
	%>
</table>
</div>
</div>
</body>
</html>